/*
 * LocalFile.java
 *
 * Created on December 3, 2006, 9:14 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package eu.somatik.somaftp.logic.local;

import eu.somatik.somaftp.logic.*;
import java.io.File;

/**
 *
 * @author francisdb
 */
public class LocalFile extends AbstractFile{
    
    private LocalFileSystem fileSystem;
    private File file;
    boolean parentDir;
    
    /** Creates a new instance of LocalFile */
    public LocalFile(File file , boolean parentDir, LocalFileSystem fileSystem) {
        this.file = file;
        this.parentDir = parentDir;
        this.fileSystem = fileSystem;
    }
    
    /** Creates a new instance of LocalFile */
    public LocalFile(File file, LocalFileSystem fileSystem) {
        this(file, false, fileSystem);
    }
    


    public String getName() {
        String name = null;
        if(isParentDir()){
            name = "..";
        }else{
            name = file.getName();
        }
        return name;
    }

    public File getFileObject() {
        return file;
    }

    public boolean isDirectory() {
        return file.isDirectory();
    }

    public boolean isLink() {
        return false;
    }


    
    public boolean isParentDir(){
        return parentDir;
    }
    
        
    public String toString(){
        return getName();
    }

    public FileSystemInterface getFileSystem() {
        return fileSystem;
    }

    public long getSize() {
        long size = 0;
        if(file.isDirectory()){
            size = -1;
        }else{
            size = file.length();
        }
        return size;
    }
    
}
